#pragma warning(disable:4996)
#include<stdio.h>

int main() {
	int a, b, temp;
	scanf("%d %d", &a, &b);
	if (a < b)
	{
		temp = a;
		a = b;
		b = temp;
	}
	while (b != 0) {
		temp = a % b;
		a = b;
		b = temp;
	}
	printf("%d", a);
	return 0;
}